def GCD(a, b):
while a % b != 0:
a, b = b, a % b
return b
def LCM(a, b):
return a * b // GCD(a, b)
l = input().split(' ')
x, y, a, b = int(l[0]), int(l[1]), int(l[2]), int(l[3])
lcm = LCM(x, y)
print(b // lcm - (a - 1) // lcm)
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main()
{
int x,y,a,b;
cin>>x>>y>>a>>b;
int lcm = x*y / __gcd(x,y);
cout<<b/lcm - (a-1)/lcm;
return 0;
}
1321A - Contest for Robots | 1451A - Subtract or Divide |
1B - Spreadsheet | 1177A - Digits Sequence (Easy Edition) |
1579A - Casimir's String Solitaire | 287B - Pipeline |
510A - Fox And Snake | 1520B - Ordinary Numbers |
1624A - Plus One on the Subset | 350A - TL |
1487A - Arena | 1520D - Same Differences |
376A - Lever | 1305A - Kuroni and the Gifts |
1609A - Divide and Multiply | 149B - Martian Clock |
205A - Little Elephant and Rozdil | 1609B - William the Vigilant |
978B - File Name | 1426B - Symmetric Matrix |
732B - Cormen --- The Best Friend Of a Man | 1369A - FashionabLee |
1474B - Different Divisors | 1632B - Roof Construction |
388A - Fox and Box Accumulation | 451A - Game With Sticks |
768A - Oath of the Night's Watch | 156C - Cipher |
545D - Queue | 459B - Pashmak and Flowers |